package com.college.heyuhua.dao;

import com.college.heyuhua.model.LostInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by 赵东坡 on 2019/2/5.
 * Time:17:13
 * 宇宙无敌赵牛逼，祈求永无bug
 */
@Mapper
@Component
public interface LostMapper {


    @Select("<script>" +
            "select * " +
            "from lostinfo " +
            "order by lid desc " +
            "limit 1000 " +
            "</script>")
    List<LostInfo> lostList();


    @Select("<script>" +
            "select * " +
            "from lostinfo l " +
            "where l.lid = #{lid} " +
            "</script>")
    LostInfo getLostById(@Param("lid") int lid);


    @Insert("<script>" +
            "insert into lostinfo (lostthings,lostaddress,lostdate,contract,telephone,uid) " +
            " values( #{info.lostthings},#{info.lostaddress},#{info.lostdate},#{info.contract},#{info.telephone},#{info.uid}) " +
            "</script>")
    boolean insertLostInfo(@Param("info") LostInfo lostInfo);

    @Delete("<script>" +
            "delete from lostinfo where lid = #{lid}" +
            "</script>")
    boolean delete(@Param("lid") String lid);
}
